﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class LocSelectionQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlDescrOper;
        protected DropDownList ddlFilterName;
        protected DropDownList ddlIsActive;
        protected DropDownList ddlIsActiveOper;
        protected DropDownList ddlSystemCreated;
        protected DropDownList ddlSystemCreatedOper;
        protected HtmlForm F2175;
        protected HtmlInputHidden hdnActionID;
        protected HtmlHead Head1;
        protected Label lblAllocateRule;
        protected Label lblDescr;
        protected Label lblFilterName;
        protected Label lblIsActive;
        protected Label lblSystemCreated;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtDescr;
        protected TextBox txtFilterName;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("LocSelectionList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["RECORDTYPE"]))
            {
                base.Server.Transfer(string.Format("LocSelectionList.aspx?action={0}&RECORDTYPE={1}", base.UrlEncode(this.hdnActionID.Value.Trim()), base.UrlEncode(base.Request.QueryString["RECORDTYPE"])), false);
            }
            else
            {
                base.Server.Transfer(string.Format("LocSelectionList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
            }
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlFilterName, 0);
            base.InitQueryDDL(this.ddlDescrOper, 0);
            base.InitQueryDDL(this.ddlIsActiveOper, 0);
            base.InitQueryDDL(this.ddlSystemCreatedOper, 0);
            base.InitIsActiveDDL(this.ddlIsActive, 0);
            base.InitIsActiveDDL(this.ddlSystemCreated, 0);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
                if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
                {
                    this.btnNew.Visible = false;
                    this.btnExport.Visible = false;
                    this.ddlIsActive.SelectedValue = "Y";
                    this.ddlIsActive.Enabled = false;
                }
            }
        }

        public string Descr
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDescr.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDescr.Text.Trim(), this.ddlDescrOper.SelectedValue);
                }
                return "";
            }
        }

        public string FilterName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtFilterName.Text.Trim()))
                {
                    return base.GetParamsString(this.txtFilterName.Text.Trim(), this.ddlFilterName.SelectedValue);
                }
                return "";
            }
        }

        public string IsActive
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsActive.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsActive.SelectedValue, this.ddlIsActiveOper.SelectedValue);
                }
                return "";
            }
        }

        public string SystemCreated
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlSystemCreated.SelectedValue))
                {
                    return base.GetParamsString(this.ddlSystemCreated.SelectedValue, this.ddlSystemCreatedOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

